home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / lights_out.swf / scripts / frame_1 / DoAction.as
Text File  |  2007-09-27  |  3KB  |  129 lines

  1. function initGame()
  2. {
  3.    curHiddenObjects = this["hiddenObjects_" + curSet];
  4.    curHiddenObjects.sort(shuffle);
  5.    initHiddenObjects();
  6.    initSetObjects();
  7.    numObjectsFound = 0;
  8.    curObjIndex = 0;
  9.    setupHiddenObject(curHiddenObjects[curObjIndex]);
  10. }
  11. function hideAllObjects()
  12. {
  13.    var _loc1_ = 0;
  14.    while(_loc1_ < numObjects)
  15.    {
  16.       backgrounds_mc["obj_" + _loc1_]._visible = false;
  17.       _loc1_ = _loc1_ + 1;
  18.    }
  19. }
  20. function setupHiddenObject(objID)
  21. {
  22.    featureText_mc.gotoAndPlay("unfound");
  23.    backgrounds_mc["obj_" + objID]._visible = true;
  24.    feature_mc.gotoAndStop("o" + objID);
  25. }
  26. function initHiddenObjects()
  27. {
  28.    var _loc3_ = 0;
  29.    while(_loc3_ < numObjects)
  30.    {
  31.       backgrounds_mc["obj_" + _loc3_].objID = _loc3_;
  32.       backgrounds_mc["obj_" + _loc3_].onPress = function()
  33.       {
  34.          _root.onObjectFound(this.objID);
  35.       };
  36.       _loc3_ = _loc3_ + 1;
  37.    }
  38.    hideAllObjects();
  39. }
  40. function initSetObjects()
  41. {
  42.    objectSets_mc.gotoAndPlay("set_" + curSet);
  43.    var _loc1_ = 0;
  44.    while(_loc1_ < curHiddenObjects.length)
  45.    {
  46.       adjustSetObjTint(curHiddenObjects[_loc1_],false);
  47.       _loc1_ = _loc1_ + 1;
  48.    }
  49. }
  50. function adjustSetObjTint(objID, found)
  51. {
  52.    var _loc1_ = undefined;
  53.    _loc1_ = new Color(objectSets_mc["set_obj_" + objID]);
  54.    if(found)
  55.    {
  56.       _loc1_.setTint(0,0,0,0);
  57.    }
  58.    else
  59.    {
  60.       _loc1_.setTint(102,0,0,100);
  61.    }
  62. }
  63. function onObjectFound(objID)
  64. {
  65.    trace("object " + objID + " found!");
  66.    featureText_mc.gotoAndPlay("found");
  67.    adjustSetObjTint(objID,true);
  68.    numObjectsFound++;
  69.    hideAllObjects();
  70. }
  71. function onFoundPayoffComplete()
  72. {
  73.    if(numObjectsFound == curHiddenObjects.length)
  74.    {
  75.       reward_mc._visible = true;
  76.       backgrounds_mc.bgLit_mc._visible = true;
  77.    }
  78.    else
  79.    {
  80.       curObjIndex++;
  81.       setupHiddenObject(curHiddenObjects[curObjIndex]);
  82.    }
  83. }
  84. function shuffle(a, b)
  85. {
  86.    return Math.floor(Math.random() * 3) - 1;
  87. }
  88. function hideRewardAssets()
  89. {
  90.    reward_mc._visible = false;
  91.    backgrounds_mc.bgLit_mc._visible = false;
  92. }
  93. function doStartOver()
  94. {
  95.    if(curSet == 1)
  96.    {
  97.       curSet = 2;
  98.    }
  99.    else
  100.    {
  101.       curSet = 1;
  102.    }
  103.    hideRewardAssets();
  104.    initGame();
  105. }
  106. function doExitActivity()
  107. {
  108.    getUrl("/Magazine/h821magazineTop.asp?curMonth=nextMonth", "");
  109. }
  110. var numObjects = 14;
  111. var hiddenObjects_1 = new Array();
  112. var hiddenObjects_2 = new Array();
  113. var curHiddenObjects = new Array();
  114. hiddenObjects_1 = [0,2,3,6,9,13];
  115. hiddenObjects_2 = [1,4,5,7,8,10];
  116. var curObjIndex;
  117. var numObjectsFound;
  118. var curSet = 1;
  119. Color.prototype.setTint = function(r, g, b, amount)
  120. {
  121.    var _loc2_ = new Object();
  122.    _loc2_.ra = _loc2_.ga = _loc2_.ba = 100 - amount;
  123.    var _loc3_ = amount / 100;
  124.    _loc2_.rb = r * _loc3_;
  125.    _loc2_.gb = g * _loc3_;
  126.    _loc2_.bb = b * _loc3_;
  127.    this.setTransform(_loc2_);
  128. };
  129.